package vrp;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

import java.io.IOException;
import javax.jdo.PersistenceManager;
import javax.servlet.http.*;

import vrp.SOrder;
import vrp.PMF;

public class SOrderDeleteServlet extends HttpServlet {

    public void doPost(HttpServletRequest req, HttpServletResponse resp)
                throws IOException {

    	PersistenceManager pm = PMF.get().getPersistenceManager();
    	
        try {
        	long sorderID = Integer.parseInt(req.getParameter("sorder"));

            Key sorderKey = KeyFactory.createKey(SOrder.class.getSimpleName(), sorderID);
            SOrder sorder = pm.getObjectById(SOrder.class, sorderKey);

            pm.deletePersistent(sorder);
        } finally {
            pm.close();
        }
        resp.sendRedirect("/sorders.jsp");
    }
}